package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.utils.BaseUtil;
import com.sx.zongzhi.view.CommentView;

import java.util.Map;

/**添加新社会组织
 * Created by admin on 2017/12/9.
 */

public class AddSocietyOrganizationPest {
    private CommentView commentView;

    public AddSocietyOrganizationPest(CommentView commentView) {
        this.commentView=commentView;
    }

    /**
     * newSocietyOrganizations.organization.id	是	string	所属网格
     newSocietyOrganizations.address	是	string	办公场所
     newSocietyOrganizations.residence	是	string	住所
     newSocietyOrganizations.name	是	string	社会组织名称
     newSocietyOrganizations.type.id	是	string	社会组织类型id(字典项名称:社会组织类型)
     newSocietyOrganizations.registrationNumbers	是	string	登记证号
     newSocietyOrganizations.state	是	string	状态(0不存在,1存在)
     newSocietyOrganizations.moneySource	是	string	资金来源
     newSocietyOrganizations.approvalDate	是	date	批准时间
     newSocietyOrganizations.attentionExtent.id	是	string	关注程度id(字典项名称:社会关注程度)
     newSocietyOrganizations.legalPersonName	是	string	法人姓名
     newSocietyOrganizations.legalSafePerson	是	string	治保负责人姓名
     newSocietyOrganizations.legalPerson	是	string	负责人姓名
     newSocietyOrganizations.cardType.id	是	string	负责人证件代码id(字典项名称:证件代码)
     newSocietyOrganizations.cardNo	是	string	负责人证件号码
     newSocietyOrganizations.registrationManagementCode	是	string	登记管理机关代码(不可超过六位)
     newSocietyOrganizations.unifiedSocialCreditCode	是	string	统一社会信用代码
     newSocietyOrganizations.legalPersonMobileNumber	是	string	负责人手机号码
     newSocietyOrganizations.legalPersonTelephone	是	string	负责人电话号码
     newSocietyOrganizations.legalSafePersonMobileNumber	是	string	治保负责人手机号码
     newSocietyOrganizations.legalSafePersonTelephone	是	string	治保负责人电话号码
     newSocietyOrganizations.isHaveOverSea	是	boolean	是否有海外背景
     newSocietyOrganizations.isHaveOrganizationCondition	是	boolean	是否具备建立中共党组织条件
     newSocietyOrganizations.isHaveOrganization	是	boolean	是否有中共党组织
     newSocietyOrganizations.isHaveGuild	是	boolean	是否有工会
     newSocietyOrganizations.isHaveGroup	是	boolean	是否有共青团组织
     newSocietyOrganizations.isHaveWomenFederation	是	boolean	是否有妇联组织
     newSocietyOrganizations.partyNum	是	int	中共党员数量
     newSocietyOrganizations.theMemeberOfGuild	是	int	工会会员数量
     newSocietyOrganizations.theMemeberOfGroup	是	int	共青团员数量
     newSocietyOrganizations.theMemeberOfWomenFederation	是	int	妇女数量
     newSocietyOrganizations.longitude	是	string	经度
     newSocietyOrganizations.latitude	是	string	纬度
     file.path	否	string	图片路径
     */
    //添加
    public void addNewSocietyOrganization(Context context, String orgId,String address, String residence,
                                           String name, String typeId, String registrationNumbers,
                                           String state, String moneySource,String approvalDate,
                                           String attentionExtentId,String legalPersonName,
                                           String legalSafePerson, String legalPerson, String cardTypeId,
                                           String cardNo, String registrationManagementCode,
                                           String unifiedSocialCreditCode, String legalPersonMobileNumber,
                                           String legalPersonTelephone, String legalSafePersonMobileNumber,
                                           String legalSafePersonTelephone, String partyNum, String theMemeberOfGuild,
                                           String theMemeberOfWomenFederation, String theMemeberOfGroup,
                                           String filePath, boolean isHaveOverSea,
                                           boolean isHaveOrganizationCondition, boolean isHaveOrganization,
                                           boolean isHaveGuild, boolean isHaveGroup, boolean isHaveWomenFederation,
                                           double longitude, double latitude){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("orgId", orgId);
        map.put("newSocietyOrganizations.address", address);
        map.put("newSocietyOrganizations.residence", residence);
        map.put("newSocietyOrganizations.name", name);
        map.put("newSocietyOrganizations.type.id", typeId);
        map.put("newSocietyOrganizations.registrationNumbers", registrationNumbers);
        map.put("newSocietyOrganizations.state", state);
        map.put("newSocietyOrganizations.moneySource", moneySource);
        map.put("newSocietyOrganizations.approvalDate", approvalDate);
        map.put("newSocietyOrganizations.attentionExtent.id", attentionExtentId);
        map.put("newSocietyOrganizations.legalPersonName", legalPersonName);
        map.put("newSocietyOrganizations.legalSafePerson", legalSafePerson);
        map.put("newSocietyOrganizations.legalPerson", legalPerson);
        map.put("newSocietyOrganizations.cardType.id", cardTypeId);
        map.put("newSocietyOrganizations.cardNo", cardNo);
        map.put("newSocietyOrganizations.registrationManagementCode", registrationManagementCode);
        map.put("newSocietyOrganizations.unifiedSocialCreditCode", unifiedSocialCreditCode);
        map.put("newSocietyOrganizations.legalPersonMobileNumber", legalPersonMobileNumber);
        map.put("newSocietyOrganizations.legalPersonTelephone", legalPersonTelephone);
        map.put("newSocietyOrganizations.legalSafePersonMobileNumber", legalSafePersonMobileNumber);
        map.put("newSocietyOrganizations.legalSafePersonTelephone", legalSafePersonTelephone);
        map.put("newSocietyOrganizations.isHaveOverSea", isHaveOverSea);
        map.put("newSocietyOrganizations.isHaveOrganizationCondition", isHaveOrganizationCondition);
        map.put("newSocietyOrganizations.isHaveOrganization", isHaveOrganization);
        map.put("newSocietyOrganizations.isHaveGuild", isHaveGuild);
        map.put("newSocietyOrganizations.isHaveGroup", isHaveGroup);
        map.put("newSocietyOrganizations.isHaveWomenFederation", isHaveWomenFederation);
        map.put("newSocietyOrganizations.partyNum", partyNum);
        map.put("newSocietyOrganizations.theMemeberOfGuild", theMemeberOfGuild);
        map.put("newSocietyOrganizations.theMemeberOfWomenFederation", theMemeberOfWomenFederation);
        map.put("newSocietyOrganizations.theMemeberOfGroup", theMemeberOfGroup);
        if (!BaseUtil.isEmpty(filePath)){
            map.put("file.path",filePath);
        }
//        map.put("newSocietyOrganizations.longitude", longitude);
//        map.put("newSocietyOrganizations.latitude", latitude);
        new ApiManager().addNewSocietyOrganization(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                commentView.commentSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                commentView.showError(message);
            }
        });
    }
    //修改
    public void updateNewSocietyOrganization(Context context, String id, String orgId,String address, String residence,
                                             String name, String typeId, String registrationNumbers,
                                             String state, String moneySource,String approvalDate,
                                             String attentionExtentId,String legalPersonName,
                                             String legalSafePerson, String legalPerson, String cardTypeId,
                                             String cardNo, String registrationManagementCode,
                                             String unifiedSocialCreditCode, String legalPersonMobileNumber,
                                             String legalPersonTelephone, String legalSafePersonMobileNumber,
                                             String legalSafePersonTelephone, String partyNum, String theMemeberOfGuild,
                                             String theMemeberOfWomenFederation, String theMemeberOfGroup,
                                             String filePath, boolean isHaveOverSea,
                                             boolean isHaveOrganizationCondition, boolean isHaveOrganization,
                                             boolean isHaveGuild, boolean isHaveGroup, boolean isHaveWomenFederation,
                                             double longitude, double latitude){
        Map<String,Object> map = HeadParamBean.getHead(context);
        map.put("newSocietyOrganizations.id", id);
        map.put("orgId", orgId);
        map.put("newSocietyOrganizations.address", address);
        map.put("newSocietyOrganizations.residence", residence);
        map.put("newSocietyOrganizations.name", name);
        map.put("newSocietyOrganizations.type.id", typeId);
        map.put("newSocietyOrganizations.registrationNumbers", registrationNumbers);
        map.put("newSocietyOrganizations.state", state);
        map.put("newSocietyOrganizations.moneySource", moneySource);
        map.put("newSocietyOrganizations.approvalDate", approvalDate);
        map.put("newSocietyOrganizations.attentionExtent.id", attentionExtentId);
        map.put("newSocietyOrganizations.legalPersonName", legalPersonName);
        map.put("newSocietyOrganizations.legalSafePerson", legalSafePerson);
        map.put("newSocietyOrganizations.legalPerson", legalPerson);
        map.put("newSocietyOrganizations.cardType.id", cardTypeId);
        map.put("newSocietyOrganizations.cardNo", cardNo);
        map.put("newSocietyOrganizations.registrationManagementCode", registrationManagementCode);
        map.put("newSocietyOrganizations.unifiedSocialCreditCode", unifiedSocialCreditCode);
        map.put("newSocietyOrganizations.legalPersonMobileNumber", legalPersonMobileNumber);
        map.put("newSocietyOrganizations.legalPersonTelephone", legalPersonTelephone);
        map.put("newSocietyOrganizations.legalSafePersonMobileNumber", legalSafePersonMobileNumber);
        map.put("newSocietyOrganizations.legalSafePersonTelephone", legalSafePersonTelephone);
        map.put("newSocietyOrganizations.isHaveOverSea", isHaveOverSea);
        map.put("newSocietyOrganizations.isHaveOrganizationCondition", isHaveOrganizationCondition);
        map.put("newSocietyOrganizations.isHaveOrganization", isHaveOrganization);
        map.put("newSocietyOrganizations.isHaveGuild", isHaveGuild);
        map.put("newSocietyOrganizations.isHaveGroup", isHaveGroup);
        map.put("newSocietyOrganizations.isHaveWomenFederation", isHaveWomenFederation);
        map.put("newSocietyOrganizations.partyNum", partyNum);
        map.put("newSocietyOrganizations.theMemeberOfGuild", theMemeberOfGuild);
        map.put("newSocietyOrganizations.theMemeberOfWomenFederation", theMemeberOfWomenFederation);
        map.put("newSocietyOrganizations.theMemeberOfGroup", theMemeberOfGroup);
        if (!BaseUtil.isEmpty(filePath)){
            map.put("file.path",filePath);
        }
//        map.put("newEconomicOrganization.longitude", longitude);
//        map.put("newEconomicOrganization.latitude", latitude);
        new ApiManager().updateNewSocietyOrganization(map, new BaseCallBack<BaseResult<Boolean>>() {
            @Override
            public void onSuccess(BaseResult<Boolean> response) {
                commentView.commentSuccess(response.getData());
            }
            @Override
            public void onFailures(String message) {
                commentView.showError(message);
            }
        });
    }

}
